<template>
  <div>
    <div class="left noScroll"
         v-show="visible">
      <div class="left-title">网格概况</div>
      <ul class="left-gummary">
        <li>
          <Icon custom="i-icon icon-leixing_renyuan"
                size="30"
                class="left-gummary-li-icon" />
          <div class="left-gummary-li-div">
            <p>作业人员</p>
            <span>0</span>
          </div>
        </li>
        <li>
          <Icon custom="i-icon icon-zhuanyunche1"
                size="30"
                class="left-gummary-li-icon" />
          <div class="left-gummary-li-div">
            <p>作业车辆</p>
            <span>0</span>
          </div>
        </li>
        <li>
          <Icon custom="i-icon icon-shanchu"
                size="30"
                class="left-gummary-li-icon" />
          <div class="left-gummary-li-div">
            <p>垃圾桶</p>
            <span>0</span>
          </div>
        </li>
        <li>
          <Icon custom="i-icon icon-sheshi"
                size="30"
                class="left-gummary-li-icon" />
          <div class="left-gummary-li-div">
            <p>绑定设施</p>
            <span>0</span>
          </div>
        </li>
      </ul>
      <div class="left-circle">
        <div class="left-circle-title">合格率</div>
        <div class="left-circle-cont">
          <i-circle :percent="100"
                    :trail-width="8"
                    :size="72"
                    :stroke-width="8"
                    stroke-color="#50C2B9">
            <span class="left-circle-cont-text">100</span>%
          </i-circle>
          <i-circle :percent="100"
                    :trail-width="8"
                    :size="72"
                    :stroke-width="8"
                    stroke-color="#D2A661">
            <span class="left-circle-cont-text">100</span>%
          </i-circle>
          <i-circle :percent="100"
                    :trail-width="8"
                    :size="72"
                    :stroke-width="8"
                    stroke-color="#7270D6">
            <span class="left-circle-cont-text">100</span>%
          </i-circle>
        </div>
      </div>
      <div class="left-polyline">
        <div>
          <p>扫路作业合格率走势</p>
          <Echarts width="330px"
                   height="130px"
                   key="sl"
                   :options="slOptions"></Echarts>
        </div>
        <div>
          <p>洒水作业合格率走势</p>
          <Echarts width="330px"
                   height="130px"
                   key="ss"
                   :options="ssOptions"></Echarts>
        </div>
        <div>
          <p>道路保洁完成率走势</p>
          <Echarts width="320px"
                   height="130px"
                   key="dl"
                   :options="dlOptions"></Echarts>
        </div>
      </div>
    </div>
    <div class="right noScroll"
         v-show="visible">
      <div class="right-top">
        <Icon custom="i-icon icon-zuojiantou"
              size="22"
              class="right-top-icon"
              @click.stop="onClickCloseIcon" />
        <p @click.stop="onClickCloseIcon">{{data.name || '--'}}</p>
      </div>
      <div class="right-msg">
        <div class="right-msg-title">责任机构：{{data.depart || '--'}}</div>
        <div class="right-msg-cont">
          <div class="right-msg-cont-item">
            <p>等级</p>
            <span>{{data.grade || '--'}}</span>
          </div>
          <div class="right-msg-cont-item">
            <p>作业面积</p>
            <span>{{data.area || '--'}}㎡</span>
          </div>
          <div class="right-msg-cont-item">
            <p>里程</p>
            <span>{{data.mileage || '--'}}m</span>
          </div>
        </div>
      </div>
      <div class="right-tabs">
        <div @click.stop="onClickRightTabs(0)"
             :class="{current : rightTabsIndex == 0}">相关资源</div>
        <div @click.stop="onClickRightTabs(1)"
             :class="{current : rightTabsIndex == 1}">作业监管</div>
      </div>
      <div class="right-list noScroll">
        <div class="noData"
             v-show="nodataVisible">
          <img src="../../../../assets/main/blank_black.png">
          <p>暂无数据</p>
        </div>
        <div class="resource-list"
             v-show="rightTabsIndex == 0">
          <p class="resource-list-title">负责人</p>
          <div class="resource-list-item">
            <div class="resource-list-item-left">
              <img src="../../../../assets/main/personImg1.png"
                   alt="">
              <div class="resource-list-item-left-right">
                <p>--</p>
                <span>
                  <Icon custom="i-icon icon-dianhua1"
                        size="16" />
                  --
                </span>
              </div>
            </div>
            <div class="resource-list-item-right">
              负责人
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Echarts from '../../../common/Echarts';
import bus from '@/utils/bus'
export default {
  components: {
    Echarts
  },
  props: {
  },
  data () {
    return {
      visible: false,
      rightTabsIndex: 0,
      nodataVisible: false,
      slOptions: {
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['05-01', '05-04', '05-07', '05-10', '05-13', '05-16', '05-19']
        },
        yAxis: {
          type: 'value',
          data: [0, 20, 40, 60, 80, 100],
        },
        series: [{
          data: [68, 28, 68, 70, 80, 100, 65, 40, 44],
          type: 'line',
          areaStyle: {
            color: '#517976'
          },
          itemStyle: {
            color: '#517976'
          }
        }],
        grid: {
          x: 0,
          y: 0,
          x2: 0,
          y2: 0,
          borderWidth: 0
        },
      },
      ssOptions: {
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['05-01', '05-04', '05-07', '05-10', '05-13', '05-16', '05-19']
        },
        yAxis: {
          type: 'value',
          data: [0, 20, 40, 60, 80, 100],
        },
        series: [{
          data: [68, 28, 68, 70, 80, 100, 65, 40, 44],
          type: 'line',
          areaStyle: {
            color: '#816A55'
          },
          itemStyle: {
            color: '#816A55'
          }
        }],
        grid: {
          x: 0,
          y: 0,
          x2: 0,
          y2: 0,
          borderWidth: 0
        },
      },
      dlOptions: {
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['05-01', '05-04', '05-07', '05-10', '05-13', '05-16', '05-19']
        },
        yAxis: {
          type: 'value',
          data: [0, 20, 40, 60, 80, 100],
        },
        series: [{
          data: [68, 28, 68, 70, 80, 100, 65, 40, 44],
          type: 'line',
          areaStyle: {
            color: '#6658B6'
          },
          itemStyle: {
            color: '#6658B6'
          }
        }],
        grid: {
          x: 0,
          y: 0,
          x2: 0,
          y2: 0,
          borderWidth: 0
        },
      },
      dataId: '',
      title: '',
      data: {},
    }
  },
  watch: {
    dataId (newVal) {
      newVal && this.getDetail()
    },
    visible (newVal) {
      if (!newVal) {
        this.dataId = ''
      }
    }
  },
  mounted () {
    this.init()
  },
  methods: {
    init () {
      bus.$on('showMainSearchGridDetail', data => {
        this.dataId = data.id
        this.title = data.title
        // 8.3暂时隐藏
        // this.visible = true
      })
    },
    getDetail () {
      this.$store.dispatch('getGridDetail', { gridId: this.dataId }).then(res => {
        this.data = res
      })
    },
    onClickRightTabs (i) {
      if (i == 1) {
        this.nodataVisible = true
      } else {
        this.nodataVisible = false
      }
      this.rightTabsIndex = i
    },
    onClickCloseIcon () {
      this.visible = false
    }
  }
}
</script>

<style lang="scss" scoped>
.left {
  width: 400px;
  position: fixed;
  top: 80px;
  bottom: 0;
  left: 8px;
  z-index: 900;
  transition: all 0.2s;
  overflow: auto;
  background: #192229;
  opacity: 0.95;
  color: #ffffff;
  border-radius: 8px;
  margin-bottom: 8px;
  padding: 16px 34px;
  .left-title {
    font-size: 24px;
    font-weight: bold;
  }
  .left-gummary {
    display: flex;
    flex-wrap: wrap;
    padding: 24px 16px 0;
    li {
      display: flex;
      width: 50%;
      align-items: center;
      margin-bottom: 28px;
      .left-gummary-li-icon {
        margin-right: 16px;
      }
      .left-gummary-li-div {
        p {
          color: rgba(255, 255, 255, 0.65);
          margin-bottom: 8px;
        }
        span {
          font-size: 18px;
          font-weight: bold;
        }
      }
    }
  }
  .left-circle {
    .left-circle-title {
    }
    .left-circle-cont {
      display: flex;
      justify-content: space-between;
      padding: 28px 16px 26px 16px;
      .left-circle-cont-text {
        font-size: 20px;
      }
    }
  }
  .left-polyline {
    overflow: auto;
    height: 57.5%;
    div {
      margin-bottom: 16px;
      p {
        margin-bottom: 8px;
      }
    }
  }
  .left-polyline::-webkit-scrollbar {
    width: 1px;
    color: #494949;
    background-color: #494949;
  }
}

.right {
  width: 400px;
  position: fixed;
  top: 80px;
  bottom: 0;
  right: 8px;
  z-index: 900;
  transition: all 0.2s;
  overflow: auto;
  background: #192229;
  opacity: 0.95;
  border-radius: 8px;
  margin-bottom: 8px;
  .right-top {
    height: 42px;
    line-height: 42px;
    padding-left: 12px;
    background: #525a60;
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: center;
    .right-top-icon {
      cursor: pointer;
    }
    p {
      cursor: pointer;
      font-size: 16px;
      font-weight: 500;
      line-height: 1;
    }
  }
  .right-msg {
    padding: 20px;
    .right-msg-title {
      color: rgba(255, 255, 255, 0.85);
      margin-bottom: 16px;
    }
    .right-msg-cont {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding-right: 40px;
      color: rgba(255, 255, 255, 0.85);
      .right-msg-cont-item {
        padding-left: 10px;
        border-left: 1px solid rgba(255, 255, 255, 0.3);
        p {
          color: rgba(255, 255, 255, 0.65);
        }
      }
    }
  }
  .right-tabs {
    display: flex;
    align-items: center;
    height: 32px;
    background: rgba(247, 247, 247, 0.1);
    padding-left: 20px;
    div {
      color: #fff;
      font-size: 16px;
      font-weight: 500;
      margin-right: 30px;
      cursor: pointer;
    }
    .current {
      color: #26bb97;
    }
  }
  .right-list {
    height: 465px;
    overflow: auto;
    .resource-list {
      padding: 10px 0 20px 0;
      margin: 0 20px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.2);
      .resource-list-title {
        margin-bottom: 10px;
        color: #fff;
      }
      .resource-list-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        color: #fff;
        .resource-list-item-left {
          display: flex;
          align-items: center;
          justify-content: space-between;
          img {
            width: 42px;
            height: 42px;
            border-radius: 50%;
            margin-right: 10px;
          }
          .resource-list-item-left-right {
            span {
              color: rgba(255, 255, 255, 0.65);
              font-size: 12px;
            }
          }
        }
        .resource-list-item-right {
          margin-left: auto;
          height: 20px;
          line-height: 20px;
          background: rgba(38, 187, 151, 0.5);
          border-radius: 4px;
          padding: 0 6px;
        }
      }
    }
  }
}
</style>
